/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
//package oop.demo.restaurantmanagementsystem;
package top.anka1.ims.RestaurantManagementSystem;
import top.anka1.ims.RestaurantManagementSystem.Meal;

import java.util.ArrayList;
/**
 * Abstract class that provides structure 
 * for the billing system
 * @author ashongtical
 * @author Anka
 */

public abstract class RestaurantBillingSystem {
    private ArrayList<Meal> menu;
    
   //Constructor to initialize the menu
    public RestaurantBillingSystem() {
        menu = new ArrayList<>();
    }

    //Add a meal to the menu
    //meal: The meal to add
    public void addMeal(Meal meal) {
        menu.add(meal);
        System.out.println("Added '" + meal.getName() + "' to the menu.");
    }

    //Remove a meal from the menu by name
    //mealName: The name of the meal to remove
    //return true if meal was removed, false otherwise
    public Boolean removeMeal(String mealName) {
        for (int i = 0; i < menu.size(); i++) {
            if (menu.get(i).getName().equalsIgnoreCase(mealName)) {
                System.out.println("Removed '" + menu.get(i).getName() + "' from the menu.");
                menu.remove(i);
                return true;
            }
        }
        System.out.println("Meal '" + mealName + "' not found on the menu.");
        return false;
    }
    
    //Display all meals on the menu
    public String displayMenu() {
        if (menu.size() == 0) {
            System.out.println("The menu is currently empty.");
            return "The menu is currently empty.";
        } else {
            String menuString = "===== MENU =====\n";
            for (int i = 0; i < menu.size(); i++) {
                menuString += (i+1) + ". " + menu.get(i).toString() + "\n";
            }
            menuString += "================\n";
            System.out.println(menuString);
            return menuString;
        }
    }

    //Find a meal on the menu by name
    //mealName: The name of the meal to find
    //The meal if found, null otherwise
    public Meal findMealByName(String mealName) {
        for (Meal meal : menu) {
            if (meal.getName().equalsIgnoreCase(mealName)) {
                return meal;
            }
        }
        return null;
    }

    //Abstract method for adding a meal for an order
    //mealName: The name of the meal to add to the order
    //return boolean indicating success or failure
    public abstract Boolean addMealToOrder(String mealName);

    //Abstract method for calculating the bill
    //return The total bill amount
    public abstract double calculateBill();
    
}
